#include "xtmotionelementfactory.h"

XtMotionElementFactory::XtMotionElementFactory() {}

void XtMotionElementFactory::showVcmDebugDlg()
{
    ShowSettingDlg();
}

SCAxis *XtMotionElementFactory::createAxis(QString name, QString axisType, QObject *parent)
{
    auto axisTypeEnum = AxisDefinition::AxisTypeEnumInfo().nameToEnum(axisType);
    switch (axisTypeEnum)
    {
        case AxisDefinition::GeneralAxis:
        {
            return new XtAxis(name, parent);
        }
        case AxisDefinition::VCM:
        {
            return new XtVcm(name, parent);
        }
    }
    qCritical() << "Unknown axis type: " << axisType;
    return nullptr;
}

SCDI *XtMotionElementFactory::createDI(QString name, QObject *parent)
{
    return new XtDI(name, parent);
}

SCDO *XtMotionElementFactory::createDO(QString name, QObject *parent)
{
    return new XtDO(name, parent);
}

ControlCard *XtMotionElementFactory::createControlCard()
{
    return new XtControlCard();
}

AxisConfig *XtMotionElementFactory::createAxisConfig(QString axisType, QObject *parent)
{
    auto type = AxisDefinition::AxisTypeEnumInfo().nameToEnum(axisType);
    switch (type)
    {
        case AxisDefinition::GeneralAxis:
        {
            return new XtAxisConfig(parent);
        }
        case AxisDefinition::VCM:
        {
            return new XtVcmConfig(parent);
        }
    }
    qCritical() << "Unknown axis type:" << axisType;
    return nullptr;
}

const QMetaObject *XtMotionElementFactory::vcmConfigMetaObje() const
{
    return &XtVcmConfig::staticMetaObject;
}

const QMetaObject *XtMotionElementFactory::axisConfigMetaObj() const
{
    return &XtAxisConfig::staticMetaObject;
}

SCDispenser *XtMotionElementFactory::createDispenser(const QLoggingCategory &logCate,
                                                     DispenserConfig *dispenserConfig,
                                                     QObject *parent)
{
    return new XtDispenser(logCate, dispenserConfig, parent);
}
